function setUp(){
	
	PicBoard.getTranslations(['lang_307_deleteCommunity'], function(){});
			
	$('#controlArea').css({
		'margin-top': '27px',
		'height': $('#UserResultArea').height() 
	});

	// Bind buttons
	
	$('#saveEdits').bind('click', function(){
		// Clicking the save button should send the gID, group name and description to the server and wait for a response.
		$.post(PicBoard.baseURL + "rsrc.php?req=updateCommunity", { instID: $('input#instID').val(), name: $('input#groupName').val(), description: $('textarea#groupDescription').val() }, function(data){
			if(data.statusCode == 200){
				alert(data.message);
			} else {
				alert(data.message);
			}
		}, 'json');			
		
	});
	
	$('#deleteCommunity').bind('click', function(){
		check = confirm(PicBoard.languageMap.lang_307_deleteCommunity);
	
		if(check){	
			$.post(PicBoard.baseURL + "rsrc.php?req=removeInstitution", { instID: $('input#instID').val() }, function(data){
				if(data.statusCode == 200){
					alert(data.message);
				} else {
					alert(data.message);
				}
			}, 'json');	
		}
	});
	
	
	$('#groupSelector').bind('change', function(){
		window.location = "managecommunities?id=" + $(this).val();
	});
	
	$('#addGroup').bind('click', function(){
		$.post(PicBoard.baseURL + "rsrc.php?req=addGroupInstitution", { instID: $('input#instID').val(), gID: $('select#addSelector').val() }, function(data){
			if(data.statusCode == 200){
				// Update UI
				
				$('.groupListHeader').after(
					$('<div>', { 'class': 'grouplistItem' }).text( $('select#addSelector').val() )
				);
				
				$('select#addSelector').children('option:selected').appendTo('select#removeSelector');
				
				// Let the user know.
				alert(data.message);
			} else {
				alert(data.message);
			}
		}, 'json');		
	});
	
	$('#deleteGroup').bind('click', function(){
		// If there is only one group in here, the user should not be able to remove it.
		if($('select#removeSelector').children().length == 1){
			alert("You must have at least one group in this community.");
			return;
		}
	
	
		$.post(PicBoard.baseURL + "rsrc.php?req=removeGroupInstitution", { instID: $('input#instID').val(), gID: $('select#removeSelector').val() }, function(data){
			if(data.statusCode == 200){
				// Update UI
				
				itemID = $('select#removeSelector').val();
				
				$('.item' + itemID).remove();
				
				$('select#removeSelector').children('option:selected').appendTo('select#addSelector');
				
				// Let the user know.
				alert(data.message);
			} else {
				alert(data.message);
			}
		}, 'json');		
	});
}

PicBoard.addLoadEvent( "setUp()" );